home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-27 | 2.2 KB | 89 lines | [TEXT/PJMM] |
- unit MySystem7;
-
- interface
-
- {Note: InitUtilities must be called prior to using functions marked * in this file }
- { (It is normally called by InitMainLoop in MyMainLoop.unit) }
-
- function MyFindFolder (vrn: integer; folder: OSType; var ovrn: integer; var oDirID: longInt): OSErr; { * }
- function MyInteractWithUser (idleproc: Ptr): OSErr; { * }
- function CreateTemporaryFile (fs: FSSpec): OSErr;
- procedure SegmentSystem7;
-
- implementation
-
- uses
- AppleTalk, Aliases, PPCToolBox, Processes, EPPC, Notification, AppleEvents, {}
- MyUtils, MyUtilities, MyNotifier, Folders, MyFileSystemUtils;
-
- const
- pref_folder = 'Preferences';
-
- {$S System7}
- procedure SegmentSystem7;
- begin
- end;
-
- {$S System7}
- function MyFindFolder (vrn: INTEGER; folder: OSType; var ovrn: INTEGER; var oDirID: LONGINT): OSErr;
- var
- oe: OSErr;
- name: str255;
- prefDirID: longInt;
- pb: HParamBlockRec;
- gv: longInt;
- begin
- oe := noErr;
- if (Gestalt(gestaltFindFolderAttr, gv) <> noErr) | (not BTST(gv, gestaltFindFolderPresent)) | (FindFolder(vrn, folder, true, ovrn, odirID) <> noErr) then begin
- oe := GetDirID(sysenv.sysVRefNum, ovrn, oDirID);
- if (oe = noErr) and (folder = kPreferencesFolderType) then begin
- name := pref_folder;
- oe := DirCreate(ovrn, oDirID, name, prefDirID);
- if oe = noErr then
- oDirID := prefDirID
- else begin
- with pb do begin
- ioNamePtr := @name;
- ioVRefNum := ovrn;
- ioDirID := oDirID;
- ioFDirIndex := 0;
- end;
- oe := PBGetCatInfo(@pb, false);
- if oe = noErr then
- oDirID := pb.ioDirID;
- end;
- oe := noErr;
- end;
- end;
- MyFindFolder := oe;
- end;
-
- {$S System7}
- function MyInteractWithUser (idleproc: Ptr): OSErr;
- var
- oe: OSErr;
- begin
- if system7 then
- oe := AEInteractWithUser(maxLongInt, nil, idleproc)
- else begin
- if in_foreground then
- MyInteractWithUser := noErr
- else begin
- Notify(true, true, 128, 0, 0, 0, 0);
- { Should wait til we are in the foreground, but its too messy }
- end;
- end;
- end;
-
- {$S System7}
- function CreateTemporaryFile (fs: FSSpec): OSErr;
- var
- oe: OSErr;
- begin
- oe := MyFindFolder(-1, kTemporaryFolderType, fs.vRefNum, fs.parID);
- if oe = noErr then
- oe := CreateUniqueFile(fs, 'trsh', 'trsh');
- CreateTemporaryFile := oe;
- end;
-
- end.